//
//  RollingView.m
//  基本框架
//
//  Created by runone02 on 2018/8/20.
//  Copyright © 2018年 liqiyun. All rights reserved.
//

#import "RollingView.h"
#import "roliingCell.h"
#import "CodeViewController.h"
#import "huanViewController.h"
#import "PushListViewController.h"
#import "FYWaveViewController.h"
#import "huabanViewController.h"
#import "GetXinlvViewController.h"
#import "BankCardViewController.h"
#import "PushBarrageViewController.h"
#import "weatherViewController.h"
#import "xiaLaViewController.h"
#import "cityWeatherViewController.h"
#import "ModelContrastViewController.h"
#import "IDAuthViewController.h"
#import "TimeViewController.h"
#import "testTimeViewController.h"
#import "FaceIDViewController.h"
#import "GifViewController.h"
#import "PubuViewController.h"
#import "TDMainViewController.h"
#import "TubiaoMainViewController.h"
#import "WaterViewController.h"
#import "HorizontalViewController.h"
#import "VerticalViewController.h"
#import "HUDViewController.h"
#import "NetWorkViewController.h"
#import "TAGViewController.h"
#import "XuanPiaoViewController.h"
#import "testUIViewController.h"
#import "TreeViewController.h"
#import "ceshishiyongViewController.h"
#import "cahanzidingyiViewController.h"
#import "DaiLiOneViewController.h"
#import "RefreshTestViewController.h"
#import "SDTableViewController.h"
#import "ZhuanViewController.h"
#import "PICViewController.h"
#import "DataCanlenderViewController.h"
#import "DayCalendarViewController.h"
#import "DINGDINGViewController.h"
#import "BGRefresh.h"
#import "MQVerCodeImageController.h"
@interface RollingView()<UICollectionViewDelegate,UICollectionViewDataSource>
/** */
@property (nonatomic, strong) UICollectionView *collectionView;
/** */
@property (nonatomic, strong) NSArray *cellArray;
@end
@implementation RollingView
static NSString *const collectionCellId = @"roliingCell";

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
        self.cellArray = @[@"卡片选择",@"长按View",@"树状列表",@"anniu",@"花瓣飘落",@"获取心率",@"我的银行卡",@"弹幕",@"天气动画",@"下拉选择",@"城市天气",@"车辆数据",@"身份证验证",@"时间选择",@"Xib时间选择",@"刷脸",@"Gif",@"瀑布流",@"指纹验证",@"图表",@"WaterViewController",@"#import HorizontalViewController.h",@"VerticalViewController",@"23",@"24",@"tag",@"电影票",@"下拉菜单",@"布局",@"ceshi",@"侧石",@"代理模式",@"京东类型刷新",@"刷新类型",@"球星转动",@"图像验证",@"选择穿衣日历",@"仿钉钉日历",@"入住酒店的天数",@"图形验证码"];
    }
    return self;
}

- (void)setupUI {
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
//    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;   //设置滚动方向
    layout.itemSize = CGSizeMake(SCREEN_WIDTH/5, SCREEN_WIDTH/5);   //设置item大小
    layout.minimumLineSpacing = 10 ;    //设置间距
    
    layout.minimumInteritemSpacing = 10 ;
    self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - SCALE_HIGHT(400)) collectionViewLayout:layout];
    
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    
    self.collectionView.showsVerticalScrollIndicator = NO;    //设置滚动条
    self.collectionView.showsHorizontalScrollIndicator = NO;
    
    self.collectionView.backgroundColor = [UIColor whiteColor];
    self.collectionView.bounces = YES;
    [self.collectionView registerClass:[roliingCell class] forCellWithReuseIdentifier:collectionCellId];

    [self addSubview:_collectionView];
    [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self);
        make.left.right.mas_equalTo(self);
        make.bottom.mas_equalTo(self).with.offset(-(10+49));
    }];
    
    //刷新控件
    BGRefresh* refresh = [[BGRefresh alloc] init];
    refresh.startBlock = ^{
//        NSLog(@"开始刷新....");
    };
    refresh.endBlock = ^{
        [self.collectionView reloadData];
    };
    refresh.isAutoEnd = YES;//设为自动结束刷新 YES/NO 自动/手动
    refresh.refreshTime = 2.0;//设置自动刷新时间(秒为单位) 手动结束刷新时不设置此项
    refresh.scrollview = self.collectionView;
}


- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.cellArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    roliingCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:collectionCellId forIndexPath:indexPath];
    cell.backgroundColor = [UIColor lightGrayColor];
    cell.NameLabel.text = self.cellArray[indexPath.row];
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        CodeViewController *code = [[CodeViewController alloc]init];
        [self.viewController.navigationController pushViewController:code animated:YES];
    }
    if (indexPath.row == 1) {
        huanViewController *huan = [[huanViewController alloc]init];
        [self.viewController.navigationController pushViewController:huan animated:YES];
    }
    if (indexPath.row == 2) {
        PushListViewController *demo = [[PushListViewController alloc]init];
        [self.viewController.navigationController pushViewController:demo animated:YES];
    }
    if (indexPath.row == 3) {
        FYWaveViewController *fw = [[FYWaveViewController alloc]init];
        [self.viewController.navigationController pushViewController:fw animated:YES];
    }
    if (indexPath.row == 4) {
        huabanViewController *piao = [[huabanViewController alloc]init];
        [self.viewController.navigationController pushViewController:piao animated:YES];
    }
    if (indexPath.row == 5) {
        GetXinlvViewController *xinlv = [[GetXinlvViewController alloc]init];
        [self.viewController.navigationController pushViewController:xinlv animated:YES];
    }
    if (indexPath.row == 6 ) {
        BankCardViewController *bancar = [[BankCardViewController alloc]init];
        [self.viewController.navigationController pushViewController:bancar animated:YES];
    }
    if (indexPath.row == 7) {
        PushBarrageViewController *push = [[PushBarrageViewController alloc]init];
        [self.viewController.navigationController pushViewController:push animated:YES];
    }
    if (indexPath.row == 8) {
        weatherViewController *weath = [[weatherViewController alloc]init];
        [self.viewController.navigationController pushViewController:weath animated:YES];
    }
    if (indexPath.row == 9) {
        xiaLaViewController *xiala = [[xiaLaViewController alloc]init];
        [self.viewController.navigationController pushViewController:xiala animated:YES];
    }
    if (indexPath.row == 10) {
        cityWeatherViewController *cityWeath = [[cityWeatherViewController  alloc]init];
        [self.viewController.navigationController pushViewController:cityWeath animated:YES];
    }
    if (indexPath.row == 11) {
        ModelContrastViewController *model = [[ModelContrastViewController alloc]init];
        [self.viewController.navigationController pushViewController:model animated:YES];
    }
    if (indexPath.row == 12) {
        IDAuthViewController *idCar = [[IDAuthViewController alloc]init];
        [self.viewController.navigationController pushViewController:idCar animated:YES];
    }
    if (indexPath.row == 13) {
        TimeViewController *time = [[TimeViewController alloc]init];
        [self.viewController.navigationController pushViewController:time animated:YES];
    }
    if (indexPath.row == 14) {
        testTimeViewController *testTime = [[testTimeViewController alloc]init];
        [self.viewController.navigationController pushViewController:testTime animated:YES];
    }
    if (indexPath.row == 15) {
        FaceIDViewController *face = [[FaceIDViewController alloc]init];
        [self.viewController.navigationController pushViewController:face animated:YES];
    }
    if (indexPath.row == 16) {
        GifViewController *gif = [[GifViewController alloc]init];
        [self.viewController.navigationController pushViewController:gif animated:YES];
    }
    if (indexPath.row == 17) {
        PubuViewController *pubu = [[PubuViewController alloc]init];
        [self.viewController.navigationController pushViewController:pubu animated:YES];
    }
    if (indexPath.row == 18) {
        TDMainViewController *td = [[TDMainViewController alloc]init];
        [self.viewController.navigationController pushViewController:td animated:YES];
    }
    if (indexPath.row == 19) {
        TubiaoMainViewController *tubiao = [[TubiaoMainViewController alloc]init];
        [self.viewController.navigationController pushViewController:tubiao animated:YES];
    }
    if (indexPath.row == 20) {
        WaterViewController *wate = [[WaterViewController alloc]init];
        [self.viewController.navigationController pushViewController:wate animated:YES];
        [MGBSHUD showSqureHUDbyText:[NSString stringWithFormat:@"这是选择了%ld",indexPath.row] fontSize:30 uiEnabled:YES delay:2.0f backgroudStyle:0 popstyle:0 imgType:MGBSHUDImgtypeCustom ifCircleColor:[UIColor yellowColor] ifCustomImg:IMAGE(@"bj_baobei") identifier:@"设置的什么"];
    }
    if (indexPath.row == 21) {
        HorizontalViewController *ho = [[HorizontalViewController alloc]init];
        [self.viewController.navigationController pushViewController:ho animated:YES];
        [MGBSHUD showImgText:[NSString stringWithFormat:@"这是%ld行",indexPath.row] fontSize:30 uiEnabled:YES delay:2.0f backgroudStyle:1 position:0 popstyle:0 imgType:MGBSHUDImgtypeCustom ifCircleColor:[UIColor redColor] ifCustomImg:IMAGE(@"bj_baobei") identifier:nil];
    }
    if (indexPath.row == 22) {
        VerticalViewController *ve = [[VerticalViewController alloc]init];
        [self.viewController.navigationController pushViewController:ve animated:YES];
        [MGBSHUD showOnlyText:[NSString stringWithFormat:@"点击了第%ld行",indexPath.row] fontSize:20 uiEnabled:YES delay:1.0f backgroudStyle:0 position:0 popstyle:0 identifier:nil];
    }
    if (indexPath.row == 23) {
        HUDViewController *hud = [[HUDViewController alloc]init];
        [self.viewController.navigationController pushViewController:hud animated:YES];
    }
    if (indexPath.row == 24) {
        NetWorkViewController *net = [[NetWorkViewController alloc]init];
        [self.viewController.navigationController pushViewController:net animated:YES];
    }
    if (indexPath.row == 25) {
        TAGViewController *tag = [[TAGViewController alloc]init];
        [self.viewController.navigationController pushViewController:tag animated:YES];
    }
    if (indexPath.row == 26) {
        XuanPiaoViewController *xuan = [[XuanPiaoViewController alloc]init];
        [self.viewController.navigationController pushViewController:xuan animated:YES];
    }
    if (indexPath.row == 27) {
        TreeViewController *tree = [[TreeViewController alloc]init];
        [self.viewController.navigationController pushViewController:tree animated:YES];
    }
    if (indexPath.row == 28) {
        testUIViewController *goodSetVc = [[testUIViewController alloc] init];
        [self.viewController.navigationController pushViewController:goodSetVc animated:YES];
    }
    if (indexPath.row == 29) {
        ceshishiyongViewController *ci = [[ceshishiyongViewController alloc]init];
        [self.viewController.navigationController pushViewController:ci animated:YES];
    }
    if (indexPath.row == 30) {
        cahanzidingyiViewController *ca = [[cahanzidingyiViewController alloc]init];
        [self.viewController.navigationController pushViewController:ca animated:YES];
    }
    if (indexPath.row == 31) {
        DaiLiOneViewController *vc = [[DaiLiOneViewController alloc]init];
        [self.viewController.navigationController pushViewController:vc animated:YES];
    }
    if (indexPath.row == 32) {
        RefreshTestViewController *vc = [[RefreshTestViewController alloc]init];
        [self.viewController.navigationController pushViewController:vc animated:YES];
    }
    if (indexPath.row == 33) {
        SDTableViewController *vc = [[SDTableViewController alloc]init];
        [self.viewController.navigationController pushViewController:vc animated:YES];
    }
    if (indexPath.row == 34) {
        ZhuanViewController *vc = [[ZhuanViewController alloc]init];
        [self.viewController.navigationController pushViewController:vc animated:YES];
    }
    if (indexPath.row == 35) {
        PICViewController *vc = [[PICViewController alloc]init];
        [self.viewController.navigationController pushViewController:vc animated:YES];
    }
    if (indexPath.row == 36) {
        DataCanlenderViewController *vc = [[DataCanlenderViewController alloc]init];
        [self.viewController.navigationController pushViewController:vc animated:YES];
    }
    if (indexPath.row == 37) {
        DINGDINGViewController *vc = [[DINGDINGViewController alloc]init];
        [self.viewController.navigationController pushViewController:vc animated:YES];
    }
    if (indexPath.row == 38) {
        DayCalendarViewController *vc = [[DayCalendarViewController alloc]init];
        [self.viewController.navigationController pushViewController:vc animated:YES];
    }
    if (indexPath.row == 39) {
        MQVerCodeImageController *vc = [[MQVerCodeImageController alloc]init];
        [self.viewController.navigationController pushViewController:vc animated:YES];
    }

}



@end
